﻿using CommunityToolkit.Mvvm.ComponentModel;
using MeasureAbstract.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MeasureAbstract.IVectorNetworkAnalyzer
{
    [INotifyPropertyChanged]
    public abstract partial class IVectorNetworkAnalyzer_V2 : IDeviceBase
    {
        public abstract string Name { get; }
        public abstract string Vender { get; }
        public abstract string Model { get; }
        public abstract string Description { get; }
        public abstract string ID { get; }
        public abstract int PortCount { get; }


        private bool _RadioFrequencyState = false;
        public bool RadioFrequencyState
        {
            get
            {
                return _RadioFrequencyState;
            }
            set
            {
                SetProperty(ref _RadioFrequencyState, value);
            }
        }

        private bool _ConnectState = false;
        public bool ConnectState
        {
            get
            {
                return _ConnectState;
            }
            set
            {
                SetProperty(ref _ConnectState, value);
            }
        }

        private bool _MalfunctionState = false;
        public bool MalfunctionState
        {
            get
            {
                return _MalfunctionState;
            }
            set
            {
                SetProperty(ref _MalfunctionState, value);
            }
        }

        public abstract void Connect();
        public abstract void DisConnect();
        public abstract void ReSet();

        //控制矢网的行为
        public abstract void CreateChannel(int ChannelNumber, long StartFrequency_Hz, long EndFrequency_Hz, int PointCount, int Average, int Smooth);
        public abstract void CreateChannel(int ChannelNumber, List<long> FrequencyList_Hz, int Average, int Smooth);
        public abstract void DeleteChannel(int ChannelNumber);

        public abstract void AddMeasure(int ChannelNumber, string MeasureName, string SParameter);
        public abstract void RemoveMeasure(int ChannelNumber, string MeasureName);

        public abstract void SetRadioFrequencyPower(double Power_dB);
        public abstract void OpenRadioFrequency();
        public abstract void CloseRadioFrequency();

        public abstract void DisplayTrace(int WindowNumber, int ChannelNumber, string MeasureName, string TraceName);
        public abstract void ClearTrace(int WindowNumber, string TraceName);

        public abstract void MeasureOnceForChannel(int ChannelNumber);
        public abstract void MeasureOnce();

        public abstract void ReadMeasureData(int ChannelNumber, string MeasureName, ref double[] Data);

        public abstract int Wait(int PollingTime_ms);

        public abstract void SetExternalTriggerIn(string Interface, TriggerSignalType TriggerSignalType, double TriggerDelay_ms = 0);
        public abstract void SetTriggerScope(TriggerScope TriggerScope);
        public abstract void SetTriggerSource(TriggerSource TriggerSource);
        public abstract void SetSweepMode(SweepMode SweepMode);
        public abstract void SetDataFormat(int ChannelNumber, string MeasurementName, DataFormat DataFormat);
        public abstract void SetScanType(int ChannelNumber, string MeasurementName, ScanType ScanType);
        public abstract void SetSweepDwellTime(double Time_ms);
        public abstract void EnablePointTrigger(bool Enable);


        public abstract void SetTriggerOut(string Interface, TriggerSignalType TriggerSignalType, double Width, double TriggerDelay_ms = 0);
        public abstract void OpenTriggerOut();
        public abstract void CloseTriggerOut();

        public abstract void SetIFBW(long Width_Hz);


        public abstract string GetLastError();
        public abstract int GetAllErrors(ref List<string> Errors);

        public abstract void SendCommands(List<string> Commands);

        /// <summary>
        /// 等待操作执行完成
        /// </summary>
        /// <param name="WaitMode"></param>
        /// <returns></returns>
        public virtual bool ActionDone(int TimeOut_S, WaitMode WaitMode = WaitMode.等应答)
        {



            return true;
        }
    }
}
